package com.biscuit.page.basicservice.model.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author biscuit
 * @createTime 2024/6/6 10:52
 */
@Getter
public enum SearchEngineTypeEnum {

    BAI_DU(1, "百度", "https://www.baidu.com/sugrec", "https://www.baidu.com/s"),
    GOOGLE(2, "谷歌", "", ""),
    BING(3, "必应", "http://cn.bing.com/AS/Suggestions", "https://cn.bing.com/search"),
    V_360(4, "360", "https://sug.so.360.cn/suggest", "https://www.so.com/s"),
    SO_GOU(5, "搜狗", "https://sor.html5.qq.com/api/getsug", "https://www.sogou.com/web");


    private final int type;
    private final String desc;

    // 源地址（获取联想词）
    private final String sourceUrl;

    // 目标地址（跳转搜索结果）
    private final String targetUrl;

    SearchEngineTypeEnum(int type, String desc, String sourceUrl, String targetUrl) {
        this.type = type;
        this.desc = desc;
        this.sourceUrl = sourceUrl;
        this.targetUrl = targetUrl;
    }

    public static SearchEngineTypeEnum getSearchEngineTypeEnumByType(int type) {
        return Arrays.stream(SearchEngineTypeEnum.values()).filter(x -> x.getType() == type).findFirst().orElse(null);
    }

}
